IF EXISTS (SELECT * FROM sysobjects WHERE name = 'GetMachinesForSrvrInstnc' AND type IN ('FN','IF','TF'))
     DROP FUNCTION dbo.GetMachinesForSrvrInstnc
GO

CREATE FUNCTION dbo.GetMachinesForSrvrInstnc
     ( @SrvrInstncId int )
RETURNS TABLE
AS
/*
 *
 * GetMachinesForSrvrInstnc
 *
 * Purpose:      
 *
 * Inputs:       
 *
 * Assumes:      
 *
 * Effects:      
 *
 * Returns:      
 *
 * Calling
 * Application:  
 *
 * Note(s):      
 *
 * Author(s):    NOVA Concepts Ltd.
 *
 * Change Log:   Initial Release, 09/29/2011, 1.00.0000
 *
 */
RETURN ( 
     SELECT m.MachineId,
            m.MachineName,
            FQMachineName = ISNULL( m.FQMachineName, CONVERT( varchar(255), m.MachineName ) )
     FROM   dbo.SrvrInstncMachine sim INNER JOIN dbo.Machine m
               ON sim.MachineId = m.MachineId
     WHERE  sim.SrvrInstncId = @SrvrInstncId
)
GO
